From d900060b28494579a305bc43b3ccb4654726a050 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 22 Feb 2010 10:06:21 +0000 Subject: [PATCH] Fix for fs-backend crash when xend was not started after system boot. Signed-off-by: Daniel Kiper --- tools/fs-back/fs-backend.c | 3 ++- tools/fs-back/fs-xenbus.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/fs-back/fs-backend.c b/tools/fs-back/fs-backend.c index 780a744655..e8882822ab 100644 --- a/tools/fs-back/fs-backend.c +++ b/tools/fs-back/fs-backend.c @@ -300,7 +300,8 @@ static void await_connections(void) LIST_INIT (&mount_requests_head); assert(xsh != NULL); - fd = xenbus_get_watch_fd(); + if ((fd = xenbus_get_watch_fd()) == -1) + err(1, "xenbus_get_watch_fd: could not setup watch"); /* Infinite watch loop */ do { FD_ZERO(&fds); diff --git a/tools/fs-back/fs-xenbus.c b/tools/fs-back/fs-xenbus.c index e883b661a0..70ddcbbf87 100644 --- a/tools/fs-back/fs-xenbus.c +++ b/tools/fs-back/fs-xenbus.c @@ -105,11 +105,18 @@ error_exit: int xenbus_get_watch_fd(void) { int res; +#if DEBUG + int errno_orig; +#endif assert(xsh != NULL); res = xs_watch(xsh, WATCH_NODE, "conn-watch"); if (!res) { +#if DEBUG + errno_orig = errno; FS_DEBUG("ERROR: xs_watch %s failed ret=%d errno=%d\n", WATCH_NODE, res, errno); + errno = errno_orig; +#endif return -1; } return xs_fileno(xsh); -- 2.30.2